package com.sdx.console.ncode.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.sdx.console.ncode.dao.RightNcodeDao;
import com.sdx.console.ncode.entity.RightNcode;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * N码 Service
 */

@Service
@Transactional
public class RightNcodeService extends BaseService<RightNcode>{

    @Resource
	private RightNcodeDao rightncodeDao;

    public PageQuery<RightNcode>queryByCondition(PageQuery query){
        PageQuery ret =  rightncodeDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelRightNcode(List<String> ids,RightNcode rightNcode){
        try {
            rightncodeDao.batchDelRightNcodeByIds(ids,rightNcode);
        } catch (Exception e) {
            throw new PlatformException("批量删除N码失败", e);
        }
    }

    public int getRightCountByCode(String ncode){
        return rightncodeDao.getRightCountByCode(ncode);
    }

    public int insertNcode(RightNcode rightNcode){
        return rightncodeDao.insertNcode(rightNcode);
    }

	public List<RightNcode> all() {
		return rightncodeDao.all();
		}

    public List<RightNcode> queryByExoprt(RightNcode rightNcode,List<String> list) {
        return rightncodeDao.queryByExoprt(rightNcode,list);
    }

    public void updateRightNcodeByIds(List<String> ids, RightNcode rightNcode,Integer provinceId) {
        rightncodeDao.updateRightNcodeByIds(ids,rightNcode,provinceId);
    }

    public void updateRightNcodeByBatchId(Integer batchId, RightNcode rightncode,Integer provinceId) {
        rightncodeDao.updateRightNcodeByBatchId(batchId,rightncode,provinceId);
    }
}
